Create base DTOs for pagination and sorting, then use IntersectionType from @nestjs/mapped-types to merge them into feature-specific DTOs. This preserves all class-validator decorators from both parent classes and ensures Swagger picks up all fields. Add a computed skip getter to the pagination base DTO for direct ORM use.
IntersectionType from @nestjs/mapped-types merges decorators from both parent classes.
Also available from @nestjs/swagger — use that version to get Swagger integration automatically.
The skip getter makes pagination DTOs directly usable with TypeORM findAndCount options.
PartialType, PickType, and OmitType are other mapped-types utilities for DTO derivation.
IntersectionType is the correct choice when you need ALL fields from both parents; PickType for a subset.